/*人员查询*/
'use strict';
const personQueryAction = require('../actions/publicUserManagement/person/personQueryAction');
const personUpdatePwdAction = require('../actions/publicUserManagement/person/personUpdatePwdAction');
const personAddAction = require('../actions/publicUserManagement/person/personAddAction');
const personDelAction = require('../actions/publicUserManagement/person/personDelAction');
const personUpdateAction = require('../actions/publicUserManagement/person/personUpdateAction');
const personEnableAction = require('../actions/publicUserManagement/person/personEnableAction');
const personResetPwdAction = require('../actions/publicUserManagement/person/personResetPwdAction');
const userDepartmentAdd = require('../actions/publicUserManagement/userDepartment/userDepartmentAddAction');
const userDepartmentDel = require('../actions/publicUserManagement/userDepartment/userDepartmentDelAction');
const userDepartmentUpdate = require('../actions/publicUserManagement/userDepartment/userDepartmentUpdateAction');
const userDepartmentQuery = require('../actions/publicUserManagement/userDepartment/userDepartmentQueryAction');
const userGroupQuery = require('../actions/publicUserManagement/userGroup/userGroupQueryAction');
const userGroupAdd = require('../actions/publicUserManagement/userGroup/userGroupAddAction');
const userGroupDel = require('../actions/publicUserManagement/userGroup/userGroupDelAction');
const userGroupUpdate = require('../actions/publicUserManagement/userGroup/userGroupUpdateAction');
module.exports = async function (ctx) {
    let param = ctx.method === 'GET' ? ctx.query : ctx.request.fields;
    let action_type = param.action_type;
    try {
        switch (action_type) {
            case 'personAdd': // 用户添加
                ctx.body = await personAddAction(param);
                break;
            case 'personDel': // 用户删除
                ctx.body = await personDelAction(param);
                break;
            case 'personUpdate': // 用户修改
                ctx.body = await personUpdateAction(param);
                break;
            case 'personEnable': // 用户启用修改
                ctx.body = await personEnableAction(param);
                break;
            case 'personUpdatePwd': // 用户修改密码
                param.user_id = ctx.session.user.user_id;
                ctx.body = await personUpdatePwdAction(param);
                break;
            case 'personQuery': // 用户查询
                ctx.body = await personQueryAction(param);
                break;
            case 'personResetPwd': // 用户重新设置密码
                ctx.body = await personResetPwdAction(param);
                break;
            case 'userDepartmentAdd': // 部门添加
                ctx.body = await userDepartmentAdd(param);
                break;
            case 'userDepartmentDel': // 部门删除
                ctx.body = await userDepartmentDel(param);
                break;
            case 'userDepartmentQuery': // 部门查询
                ctx.body = await userDepartmentQuery(param);
                break;
            case 'userDepartmentUpdate': // 部门修改
                ctx.body = await userDepartmentUpdate(param);
                break;
            case 'userGroupAdd': // 角色增加
                ctx.body = await userGroupAdd(param);
                break;
            case 'userGroupDel': // 角色删除
                ctx.body = await userGroupDel(param);
                break;
            case 'userGroupUpdate': // 角色修改
                ctx.body = await userGroupUpdate(param);
                break;
            case 'userGroupQuery': // 角色查询
                ctx.body = await userGroupQuery(param);
                break;

        }
    } catch (e) {
        ctx.body = {success: false, message: e.message};
    }

};